public class Solution151 {
    public String reverseWords(String s) {
        s = s.trim();
        if (s.length() == 0) {
            return s;
        }
        int i = 0;
        for (; i < s.length(); i++) {
            if (s.charAt(i) == ' ') {
                break;
            }
        }
        if (i == s.length()) {
            return s;
        } else {
            return reverseWords(s.substring(i)) + " " + s.substring(0, i);
        }
    }
}
